using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMRubros
    {
        public BMRubros(string coneccion) 
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        private Rubros oRubro = new Rubros();
        private List<Rubros> listaRubros = new List<Rubros>();
        private DARubros daRubros = new DARubros();

        #region BMRubrosSearch
        public List<Rubros> BMRubrosSearch(Rubros rubro)
        {
            try
            {
                listaRubros = daRubros.DARubrosSearch(connection, rubro);
                return listaRubros;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRubrosInsert
        public Rubros BMRubrosInsert(Rubros rubro)
        {
            try
            {
                rubro = daRubros.DARubrosInsert(connection, rubro);
                return rubro;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMRubrosUpdate
        public void BMRubrosUpdate(Rubros rubro)
        {
            try
            {
                daRubros.DARubrosUpdate(connection, rubro);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}